<template>
    <div class="article">
        <div class="left">
            <el-image style="height: 143px;" :src="url" fit="fill">
            </el-image>
        </div>
        <div class="right">
            <div class="right-top" @click="goArticle(item.blogId)">{{ item.title }}</div>
            <div class="right-middle">这个人很懒，暂时还没有简介</div>
            <div class="right-bottom">
                <div class="click" @click="addZan"><i class="el-icon-circle-check" :style="{ color: isZan ? 'red' : '' }"></i><span :style="{ color: isZan ? 'red' : '' }">{{ item.likes }}</span> 赞</div>
                <div class="click" @click="addCai"><i class="el-icon-circle-close" :style="{ color: isCai ? 'red' : '' }"></i><span :style="{ color: isCai ? 'red' : '' }">{{ item.disLike }}</span> 踩</div>
                <div class="author">作者: {{ item.author }}</div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props:["item"],
    data(){
        return {
            isZan:false,
            isCai:false,
            url:this.item.coversUrl
        }
    },
    methods:{
        addZan(){
            if(this.isZan === false){
                this.item.likes++
                this.isZan = true
            }
        },
        addCai(){
            if(this.isCai === false){
                this.item.disLike++
                this.isCai = true
            }
        },
        goArticle(id){
            this.$router.push({ name: 'article', params: { id: id } })
        },
    },
    mounted() {
        
    },
}
</script>

<style lang="less" scoped>
.article{
    height: 143px;
    padding: 10px 0;
    display: flex;
    border-bottom: 1px solid #f0f0f2;
    .left{
        text-align: center;
        width: 20%;
        height: 143px;
        margin-right: 16px;
    }
    .right{
        padding: 10px 0;
        .right-top{
            font-size: 20px;
        }
        .right-middle{
            color: #555666;
            padding: 10px 0;
        }
        .right-top:hover,.right-middle:hover{
            background-color: #f0f0f2;
            cursor: pointer;
        }
        .right-bottom{
            display: flex;
            margin-top: 40px;
            font-size: 14px;
            color: #555666;
            .click{
                width: 70px;
                i{
                    margin-right: 5px;
                }
            }
            .click:hover{
                cursor: pointer;
            }
            .author{
                color: #555666;
            }
        }
    }
}
.article:hover{
    background-color: #f0f0f2;
}
</style>